﻿using System;

namespace OrderWorkflow.OrderWorkflowWithGeneratedCode
{
    public partial class OrderWorkflowWithGeneratedCode
    {
        public bool StocksAreOk { get; set; }

        public string ExecuteAutomaticStep(string stepName)
        {
            string nextTransitionName;

            switch (stepName)
            {
                case OrderWorkflowWithFrameworkSteps.AreAllItemsOnStockDecisionStep:
                    if (StocksAreOk)
                    {
                        nextTransitionName = OrderWorkflowWithFrameworkTransitions.ItemsAreAvailable;
                    }
                    else
                    {
                        nextTransitionName = OrderWorkflowWithFrameworkTransitions.ItemsAreMissing;
                    }

                    break;
                case OrderWorkflowWithFrameworkSteps.SendNotificationEmailToCustomerAutomaticStep:

                    //TODO: send an email here to the customer

                    nextTransitionName = OrderWorkflowWithFrameworkTransitions.EmailSent;
                    break;

                default:
                    throw new NotImplementedException(stepName + " is not implemented in ExecuteAutomaticStep override.");

            }

            return nextTransitionName;
        }

    }
}
